import axios from 'axios'

const instance = axios.create({
  baseURL: GITHUB_API,
  timeout: 10000
  // transformRequest: [function (data, headers) {
  //   // Do whatever you want to transform the data
  //   headers["Authorization"] = "token " + localStorage.getItem("token");
  //   return data;
  // }]
});

instance.interceptors.request.use (function (config) {
  config.headers["Authorization"] = "token " + localStorage.getItem("token");
  return config;
});


instance.interceptors.response.use (function (r) {
  console.log(r)
  return r;
}, function (error) {
   // if (error.response.status  && 401 === error.response.status) {
   //   localStorage.removeItem("token")
   // } else {
   //   alert(error);
   //   // return Promise.reject(error)
   // }
});

export default instance
